import requests
# 本文件用于测试query文件
# 更改query参数可获得不同结果
url = "http://localhost:5000/api/query"
data = {"query": "测试查询"}

try:
    response = requests.post(url, json=data)
    print(response.status_code)  # 检查状态码
    print(response.text)  # 打印响应内容
    response.raise_for_status()  # 确保状态码为 200
    json_response = response.json()  # 尝试解析 JSON
    print(json_response)

except requests.exceptions.HTTPError as err:
    print(f"HTTP error occurred: {err}")  # 捕获 HTTP 错误
except requests.exceptions.RequestException as e:
    print(f"Error: {e}")  # 捕获其他请求错误
except ValueError as e:
    print(f"JSON de code error: {e}")  # 捕获 JSON 解码错误